package systempen.cmanager;

import java.util.List;
import systempen.cmanager.R;
import android.content.Context;
import android.content.res.ColorStateList;
import android.graphics.Color;
import android.graphics.Typeface;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

public class AccountListAdapter extends ArrayAdapter<AccountListItem> {

	private List<AccountListItem> items;

	public AccountListAdapter(Context context, int textViewResourceId, List<AccountListItem> items) {
		super(context, textViewResourceId, items);
		this.items = items;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		View v = convertView;
		if (v == null) {
			LayoutInflater vi = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
			v = vi.inflate(R.layout.accountlist_row, null);
		}
		AccountListItem o = items.get(position);
		if (o != null) {
			TextView tvId = (TextView) v.findViewById(R.id.account_code);
			if (tvId != null) {
				tvId.setText(o.getAccount_code());
			}
			TextView tvAccountName = (TextView) v.findViewById(R.id.account_name);
			if (tvAccountName != null) {
				tvAccountName.setText(o.getAccount_name());
			}
			TextView tvAccountSum = (TextView) v.findViewById(R.id.account_sum);
			if (tvAccountSum != null) {
				tvAccountSum.setText(o.getAccount_sum());
			}
		}
		return v;
	}
}